Skip to content

Conversation

shreefAhmedM
Copy link

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Her is JavaScript challenges tasks covering running test, error fixing, code interpretation, and a stretch exploration activity.

@shreefAhmedM shreefAhmedM added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Sep 28, 2025
@LonMcGregor LonMcGregor added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Oct 7, 2025
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start on this sprint's tasks, most of it is really good. I have spotted a few areas where you could improve code further

// write one test at a time, and make it pass, build your solution up methodically
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers
function getCardValue(card) {
let rank = card.length === 1 ? card : card.slice(0, -1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What circumstances would you have a card of length 1? A card in this case is always a rank + a symbol

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What circumstances would you have a card of length 1? A card in this case is always a rank + a symbol

Thanks for pointing that. I checked that if the card is a single character (length 1) for example, "A" it returns 10 which is not true , because this line ( let rank = card.length === 1 ? card: card.slice(0, -1); ) is handling the case where the card is only one character long, Instead of the card should always include both the rank and the suit.
i have updated the function.

});
// Case 3: Handle Face Cards (J, Q, K):
test("should return the value 10, a card with a rank of ('10', 'J', 'Q', or 'K')", () => {
const aceofSpades = getCardValue("K");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment I gave above - This is a king, but which king, hearts? spades?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, i updated

if (last2Digit >= 11 && last2Digit <= 13) {
return num + "th";
}
if (las1Digit === 1) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you have a long series of if checks like this, is there another conditional structure that might be more appropriate to use?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated that one using switch case i thnk is more appropiate.

}

module.exports = passwordValidator;
if (oldPassword.includes(password)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you simplify this final check?

@LonMcGregor LonMcGregor added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Oct 7, 2025
@shreefAhmedM shreefAhmedM added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 10, 2025
Copy link

@LonMcGregor LonMcGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. These changes look good to me.I just have one very minor additional suggestion.

// write one test at a time, and make it pass, build your solution up methodically
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers
function getCardValue(card) {
let rank = card.slice(0, -1);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way you could simplify this slice even more?

(Hint: You can achieve the same thing with only one argument to slice)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated, thanks

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not really thinking about the card length - I was more thinking about the .slice function itself. Here you are passing 2 arguments, 0 and -1. Did you know you can call .slice with only a single argument?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants